import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/actReModel/createModel',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/actReModel/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/actReModel',
    method: 'put',
    data
  })
}

/**
 * 部署流程
 * @param {*} id
 * @returns
 */
export function deploy(id) {
  return request({
    url: 'api/actReModel/deploy/' + id,
    method: 'put'
  })
}

/**
 * 导出文件
 * @param {*} id
 * @returns
 */
export function downloadBpmn(id) {
  return request({
    url: '/api/activiti/downloadBpmn/' + id,
    method: 'get',
    responseType: 'blob'
  })
}

/**
 * 获取全部流程模型
 * @returns
 */
export function getAllModels() {
  return request({
    url: 'api/actReModel/getAllModels',
    method: 'get'
  })
}

export default { add, edit, del, deploy, downloadBpmn, getAllModels }
